import React, { PureComponent, Fragment } from 'react';
import { connect } from 'dva';
import router from 'umi/router';
import {Icon} from 'antd';
import PageHeaderLayout from '../../layouts/PageHeaderLayout';
import styles from '../Pbulic.less';


const tabList = [
  {
    key: "info",
    tab: "路线详情",
    // authority: "050101"
  },
  {
    key: "curing",
    tab: "路线养护点配置",
    // authority: "050201"
  }
];


@connect(({global }) => ({
  dictionaries:global.dictionaries,
}))
export default class EquipmentDetail extends PureComponent {
  constructor(props) {
    super(props);
  }


  componentDidMount() {

  }

  componentWillUnmount(){
    const { dispatch } = this.props;
    dispatch({
      type: `path/appendClearState`,
    })
  }


  goBack = () => {
    // this.props.onClose(0);
    const { dispatch, location } = this.props;

    router.push({ pathname:'/maintain/route/list',  query: { ...location.query} });
  }

  render() {
    const { match, history, routerData, children} = this.props;

    const location_arry = history.location.pathname.split("/");
    const tabDefaultKeys = location_arry[location_arry.length - 1];
    const detailId = match.params.id;


    // const tabDefaultTitle = [{title:tabList.find(item=>item.key==tabDefaultKeys).tab}];

    return (
      <Fragment>
        <Icon type="close-circle-o"  className={styles.close_icon} onClick={this.goBack}/>
        <PageHeaderLayout
          hiddenBreadcurmb={true}
          title={tabList.find(item=>item.key==tabDefaultKeys).tab}
        >
          {children}

        </PageHeaderLayout>
      </Fragment>
    );
  }
}
